package com.hns.can.energy.service;

import java.util.List;
import java.util.Map;

import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hns.can.master.service.TendencyChartsDataTools;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;

/**
 * 能耗首页service
 * @author:zhangyu
 * @email:zhangyu2222z@sina.cn
 * @version Revision 2.0.0
 */
@Service
public class HomeEnergyService extends CommonService {

	@Autowired
	private TendencyChartsDataTools tendencyChartsDataTools;	//趋势图补充数据工具
	
	/**
	 * 加载能耗首页数据通用方法
	 * @param funcType 功能类型
	 * @param map	参数
	 * @param clazzName	转化类型字符串
	 * @return
	 * @throws Exception
	 * @author:zhangyu
	 * @email:zhangyu2222z@sina.cn
	 */
	@SuppressWarnings("unchecked")
	public List<T> callMethod(String funcType,
			Map<String, Object> map, String clazzName) throws Exception{
		Class<?> clazz = Class.forName("com.hns.can.energy.vo."+clazzName);
		List list = this.sqlMapDao.selectList("homeEnergy."+funcType, map);
		//TODO 补充趋势图缺失数据 暂时屏蔽
		if("energyTendencyChart".equals(funcType) && PubUtil.isNotEmpty(list)){
			list = tendencyChartsDataTools.fillEnergySingleTendencyData(list, (String)map.get("dateType"));
		}else if("energyCostTendency".equals(funcType) && PubUtil.isNotEmpty(list)){
			list = tendencyChartsDataTools.fillSafetyMultiTendencyData(list, (String)map.get("dateType"));
		}
		list = PubUtil.convertListMapToObject(list, clazz);
		return list;
	}

}
